<template>
  <div class="container-item-swiper">
    <div class="swiper">
      <van-swipe :autoplay="3000">
        <van-swipe-item v-for="(temp, index) in list" :key="index" class="swiper-item" @click="routerLink(`productDetails`, temp.product_id)">
          <van-image width="100%" class="item-cover" :src="temp.img" fit="cover" />
        </van-swipe-item>
      </van-swipe>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default() {
        const arr = [
          { product_id: 1, img: 'http://placehold.it/1600x900' },
          { product_id: 1, img: 'http://placehold.it/1600x900' },
          { product_id: 1, img: 'http://placehold.it/1600x900' }
        ]
        return arr
      }
    }
  },
  methods: {
    routerLink(name, id) {
      console.log('轮播图点击-log:', name, id)
      this.$router.push({ name, params: { id }})
    }
  }
}
</script>

<style lang="less">
.container-item-swiper {
  padding-bottom: 10px;
  min-height: 220px;
  .swiper-item {
    padding: 0 5px;
    overflow: hidden;
    .item-cover {
      width: 100%;
      // height: 100%;
      height: 200px;
      display: block;
      margin: 3px 0;
      border-radius: 10px;
      overflow: hidden;
      box-shadow: 0 0 1px #aaa;
    }
  }
}
</style>
